|
|
|
|
|
|
|
Figure 4.10
Checkbox-style list boxes provide the users
with an intuitive way to select multiple items. |
|
|
|
|
|
|
|
|
umns). When the list is displayed in multiple columns, the list scrolls horizontally. You can use the Columns property with either the Standard or Checkbox styles of lists. Figure 4.11 shows single-column and multicolumn lists. The list works the same way no matter how many columns you use. |
|
|
|
|
|
|
|
|
Figure 4.11
You also can create multicolumn lists. |
|
|
|
|
|
|
|
|
Working with Multiple Selections |
|
|
|
|
|
|
|
|
Sometimes you need to let the users select more than one item from a list. The list box supports this capability with the MultiSelect property. This property has three possible settings: 0 - None, 1 - Simple, and 2 - Extended: |
|
|
|
|
|
|
|
|
The default setting, 0 - None, means that multiple selections are not permitted, and the list box can accept only one selection at a time. The other two settings both permit multiple selections; the difference is in how they let the users make selections. |
|
|
|
|
|
|
|
|
With a setting of 1 - Simple, users can click an item with the mouse to select it or click a selected item to deselect it. If they use the keyboard to make the selection, they can use the cursor keys to move the focus (the dotted line border) to an item and then press the Spacebar to select or deselect it. |
|
|
|
|
|
|
|
|
The other setting of the MultiSelect property, 2 - Extended, is more complex. In this mode, users can use standard Windows techniques to quickly select multiple items. They can select a range of items by clicking the first item in the range and then, while holding down the Shift key, clicking the last item in the range; all items in between the first and last item are selected. To add or delete a single item to or from this selection, users hold down the Ctrl key while clicking the item. |
|
|
|
|
|
|
|
|
Getting the selections from a multiple-selection list box is a little different than getting them for a single selection. Because the ListIndex property works only for a single selection, you can't use it. Instead, you have to examine each item in the list to determine whether it is selected. |
|
|
|
|
|